package me.softwareengineer.guice.rendering.domain;

import java.util.List;
import java.util.Map;

import me.softwareengineer.guice.rendering.listener.EndParagraphEvent;
import me.softwareengineer.guice.rendering.listener.Listener;
import me.softwareengineer.guice.rendering.listener.StartParagraphEvent;

/**
 * Represents a paragraph
 * 
 * @author yad.tahir
 * 
 *         <pre>
 * This class is thread-safe and can be cached/re-used and used concurrently.
 * </pre>
 */
public class ParagraphElement extends Element {
	/**
	 * Creates a paragraph element without properties
	 * 
	 * @param children
	 *            the children elements of the pragraph
	 */
	public ParagraphElement(List<Element> children) {
		super(children);
	}

	/**
	 * Creates a paragraph element without properties
	 * 
	 * @param children
	 *            the children elements of the pragraph
	 * @param properties
	 *            the properties of the paragraph. For more info, check
	 *            {@link HasProperties}
	 */
	public ParagraphElement(List<Element> children,
			Map<String, String> properties) {
		super(children);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void afterElement(Listener l) {
		EndParagraphEvent e = new EndParagraphEvent(getAllProperties());
		l.onEvent(e);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void beforeElement(Listener l) {
		StartParagraphEvent e = new StartParagraphEvent(getAllProperties());
		l.onEvent(e);
	}

}
